using Microsoft.SharePoint;
using SP.ListItem.WordExporter.Utils;
using System.Runtime.InteropServices;
using Constants = SP.ListItem.WordExporter.Utils.Constants;

namespace SP.ListItem.WordExporter.Features
{
    [Guid("55a52460-d254-43c3-9981-3b1f796e2a72")]
    public class SPListItemWordExporterFeatureEventReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            var web = properties.Feature.Parent as SPWeb;
            var templatesList = web.EnsureList(Constants.Lists.Templates, Constants.Lists.TemplatesDescription, SPListTemplateType.DocumentLibrary);
            var field = templatesList.EnsureField(Constants.Fields.TemplatesListTitle);
            var defaultView = templatesList.DefaultView;
            defaultView.ViewFields.Add(field);
            defaultView.Update();
            templatesList.Update();
        }
    }
}
